#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

int numSubarrayProductLessThanK(vector<int>& nums, int k) {
    int cnt = 1, res = 0, i = 0;
    for (int j = 0; j < nums.size(); j++)
    {
        cnt *= nums[j];
        while (i <= j && cnt >= k)
            cnt /= nums[i++];
        res += j - i + 1;
    }
    return res;
}